export function convertToLocalUrl(localFilePath, serverIp, port) {
    // 定义本地文件路径的根目录
    // const rootDirectory = "D:\\work_station\\fullstack\\axcbd\\front_end\\demo\\public\\motion_frames\\";
    const rootDirectory = "motion_frames/";

    // 替换根目录为 "/images/"
    let relativePath = localFilePath.replace(rootDirectory, "/images/");

    // 构建完整的 URL
    const baseUrl = `http://${serverIp}:${port}`;
    const fullUrl = `${baseUrl}${relativePath}`;

    return fullUrl;
}



// 示例用法
const localFilePath = "D:\\work_station\\fullstack\\axcbd\\front_end\\demo\\public\\motion_frames\\20250623_165653_750942.jpg";
const serverIp = "localhost"; // 替换为实际的服务器 IP 地址
const port = "8080"; // 替换为实际的端口号

const url = convertToLocalUrl(localFilePath, serverIp, port);
console.log(url); // 输出: http://192.168.1.100:8080/images/20250623_165653_750942.jpg